import React, { Component } from 'react'
import { Redirect } from 'react-router'
import {Layout} from 'antd'
import memoryUtils from '../../utils/memoryUtils'
import Header from '../../components/header'
import LeftNav from '../../components/left-nav'
import Route from '../index'

const { Footer, Sider, Content} = Layout;
export default class Admin extends Component {
  render() {
    // 获取user
    const user = memoryUtils.user
    //如果内存中没有存储user , 说明当前没有登录，需要跳转到登录页
    if (!user || !user.id) {
      // 在 render 中 自动跳转到登录页
      return <Redirect to='/login'/>
    }
    return (
      <Layout style={{height:'100%'}}>
        <Sider >
          <LeftNav/>
        </Sider>
        <Layout>
          <Header user={user}></Header>
          <Content style={{backgroundColor: '#fff'}}>
            {/* 路由匹配 */}
            <Route/>
          </Content>
          <Footer style={{textAlign: 'center',fontSize: '16px',color: '#ccc'}}>版权所有@1413777982@qq.com</Footer>
        </Layout>
      </Layout>
    )
  }
}
